
package com.lcy;

import com.lcy.dao.SmbmsUserDao;
import com.lcy.entry.SmbmsUser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class MainTest {
    public static void main(String[] args){
        String config = "mybatis-config.xml";

        try{
            InputStream inputStream = Resources.getResourceAsStream(config);
            SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
            SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(inputStream);
            SqlSession sqlSession = sqlSessionFactory.openSession();
            SmbmsUserDao smbmsUserDao = sqlSession.getMapper(SmbmsUserDao.class);
            SmbmsUser smbmsUser = smbmsUserDao.getSmbmsUserByUserCode("admin");
            System.out.println(smbmsUser);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
